/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.txweb.table;

import com.jspx.boot.sign.MappingType;
import com.jspx.sober.annotation.*;
import com.jspx.sober.table.OperateTable;
import com.jspx.utils.StringUtil;

/**
 * Created by IntelliJ IDEA.
 * User: chenYuan
 * Date: 2010-12-2
 * Time: 15:19:36
 * 因为有多个软件，和多个角色的对应关系，所以要单独做一个角色表，保存用户和角色的关闭
 * 角色和用户不是一对一关系，而是一对多的关系
 */
@Table(name = "jspx_member_role", caption = "用户角色", cache = true, cacheName = "roleCache")
public class MemberRole extends OperateTable {
    @Id(auto = true, type = IDType.serial)
    @Column(caption = "ID", notNull = true)
    private int id;

    @Column(caption = "用户ID", notNull = true)
    private long uid = 0;

    @Column(caption = "权限角色ID", notNull = true)
    private int roleId = 0;

    @Nexus(mapping = MappingType.OneToOne, name = "roleId", targetName = "id", targetEntity = Role.class, delete = false, where = "${roleId!=0}")
    private Role role = new Role();

    @Column(caption = "命名空间", length = 50, notNull = true)
    private String namespace = StringUtil.empty;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }
}